import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex)

const state={
    projectId:1,
    token:'',
    userId:0
};
const getters={
    getProjectId(){
        return state.projectId
    },
    getToken(){
      return state.token
    },
  getUserId(){
    return state.userId
  }
};

const mutations ={
    newProjectId(state,id){
        state.projectId= id;
    },
    newToken(state,token){
        state.token=token;
  },
  newUserId(state,userId){
    state.userId=userId;
  }
};

const actions ={
    getNewProjectId(context,id){
        context.commit('newProjectId',id)
    },
    getNewToken(context,token){
    context.commit('newToken',token);
  },
  getNewUserId(context,userId){
    context.commit('newUserId',userId);
  }
}

const store =new Vuex.Store({
    state,
    getters,
    mutations,
    actions
})

export default store;
